/*********************************************************
          File Name:16.4.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Sat 12 Dec 2015 12:43:19 PM CST
**********************************************************/

#include <iostream>
#include <vector>
#include <list>
#include <string>

using std::vector;
using std::list;
using std::string;
using std::cout;
using std::endl;

namespace nm
{
        template<typename T, typename Type>
        T find(T beg, T end, const Type &x)
        {
                for(; beg != end && x != *beg; ++beg);
                return beg;
        }
}

int main(void)
{
        vector<int> v{1, 2, 3, 4, 5};
        list<string> l{"this", "is", "a", "test"};

        auto ires = nm::find(v.begin(), v.end(), 0);

        if(ires != v.end())
                cout << *ires << endl;
        else
                cout << "not found" << endl;

        auto sres = nm::find(l.begin(), l.end(), "a");

        if(sres != l.end())
                cout << *sres << endl;

        return 0;
}
